#import "FFTableViewController.h"
#import "UIColor+Expand.h"

#define kFFTableViewSeperatorCell @"FFTableViewSeperatorCell"

@interface FFTableViewController () <MCUTableViewSectionDataSource>

@end

@implementation FFTableViewController

#pragma mark life

- (void)viewDidLoad {
    [super viewDidLoad];
     self.automaticallyAdjustsScrollViewInsets = NO;
    [self.view addSubview:self.tableView];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kFFTableViewSeperatorCell];
}

- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
    self.tableView.frame = self.view.bounds;
}

#pragma mark 业务方法

-(NSArray *)customSections {
    return [NSArray array];
}

#pragma mark - 分隔块

- (NSNumber*)splitSectionHeightOfCellWithIndexPath:(NSIndexPath*)indexPath {
    return @12;
}

- (UITableViewCell*)splitSectionCellForRowWithIndexPath:(NSIndexPath*)indexPath {
    return [self cellForSeperator];
}

- (NSNumber*)splitSectionNumberOfRowWithSection:(NSNumber*)section {
    return @1;
}

- (UITableViewCell*)cellForSeperator {
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:kFFTableViewSeperatorCell];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.contentView.backgroundColor = [UIColor colorWithHexString:@"F6F6F8"];
    return cell;
}

#pragma mark 控件

- (MCUTableView *)tableView
{
    if(_tableView == nil)
    {
        _tableView = [[MCUTableView alloc]init];
        _tableView.sectionDataSource = self;
        _tableView.backgroundColor = [UIColor colorWithRed:248/255.0 green:248/255.0 blue:248/255.0 alpha:1.0];
    }
    return _tableView;
}

-(MCUTableCustomSection *)splitSection{
    if (_splitSection == nil) {
        _splitSection = [MCUTableCustomSection createWithTarget:self];
        _splitSection.heightForCellSelector =
        @selector(splitSectionHeightOfCellWithIndexPath:);
        _splitSection.numberOfRowsSelector =
        @selector(splitSectionNumberOfRowWithSection:);
        _splitSection.cellForRowAtIndexSelector = @selector(splitSectionCellForRowWithIndexPath:);
    }
    return _splitSection;
}

@end
